Skip to content

Add optional reasons to karma voting - #294

Open
konard wants to merge 3 commits into
mainfrom
issue-117-b93d3637
Open

Add optional reasons to karma voting#294
konard wants to merge 3 commits into
mainfrom
issue-117-b93d3637

Conversation

@konard

@konard konard commented Sep 13, 2025

Copy link
Copy Markdown
Member

Summary

Implements optional reasons for karma voting as requested in issue #117.

  • ✅ Added support for optional reasons after karma operators (e.g., + решение сработало, - вопрос недостаточно конкретный)
  • ✅ Modified regex pattern to capture reasons while maintaining backward compatibility
  • ✅ Updated karma change messages to display reasons when provided
  • ✅ Added comprehensive tests for the new functionality

Changes Made

1. Regex Pattern Updates (patterns.py)

  • Modified APPLY_KARMA pattern to capture optional reasons using (?:\s+(?P<reason>.+?))?
  • Maintains full backward compatibility with existing karma voting formats

2. Commands Logic (commands.py)

  • Updated apply_karma() method to extract reason from matched pattern
  • Modified apply_karma_change() signature to accept optional reason parameter
  • Ensured reason is passed through to message building

3. Message Building (commands_builder.py)

  • Enhanced build_karma_change() to include reasons in karma change notifications
  • Formats reasons as Причина: {reason} when present
  • Works for both collective votes and personal karma transfers

4. Testing (tests.py)

  • Updated existing test to work with new method signature
  • Added comprehensive test case for karma reasons functionality

Examples

Input Result
+ решение сработало Collective positive vote with reason "решение сработало"
- вопрос недостаточно конкретный Collective negative vote with reason "вопрос недостаточно конкретный"
+5 отличная помощь Transfer 5 karma with reason "отличная помощь"
+ Standard collective positive vote (no change)

Test Plan

  • Verified regex pattern matches all required formats
  • Tested message building with and without reasons
  • Confirmed backward compatibility with existing karma voting
  • Added unit tests for new functionality

Fixes #117

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #117
@konard konard self-assigned this Sep 13, 2025
- Modified APPLY_KARMA regex pattern to capture optional reasons after karma operators
- Updated apply_karma method to extract and pass reason parameter
- Enhanced build_karma_change to display reasons in karma change messages
- Added test case for karma reasons functionality
- Supports formats like "+ решение сработало" and "- вопрос недостаточно конкретный"

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Add optional reasons to karma voting Add optional reasons to karma voting Sep 13, 2025
@konard
konard marked this pull request as ready for review September 13, 2025 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add optional reasons to karma voting

1 participant